﻿
Imports osi.root.connector
Imports osi.root.utils
Imports osi.service.argument

Public Enum zip_mode
    bypass
    bypass2
    gzip
    deflate
End Enum

Public Module _create
    Public ReadOnly bypass_mode As String = zip_mode.bypass.ToString()

    Public Function create(ByVal parameter As String, ByRef o As zipper) As Boolean
        Return create(New var(parameter), o)
    End Function

    Public Function create(ByVal parameters As var, ByRef o As zipper) As Boolean
        If parameters Is Nothing Then
            Return False
        Else
            Dim mode As zip_mode = Nothing
            If parameters.other_values().empty() OrElse
               Not enum_cast(parameters.other_values()(0), mode) Then
                Return False
            Else
                Select Case mode
                    Case zip_mode.bypass
                        Return bypass.create(parameters, o)
                    Case zip_mode.bypass2
                        Return bypass2.create(parameters, o)
                    Case zip_mode.gzip
                        Return gzip.create(parameters, o)
                    Case zip_mode.deflate
                        Return deflate.create(parameters, o)
                    Case Else
                        Return False
                End Select
            End If
        End If
    End Function

    Public Function create(ByVal parameter As String) As zipper
        Dim o As zipper = Nothing
        assert(create(parameter, o))
        Return o
    End Function

    Public Function create(ByVal parameters As var) As zipper
        Dim o As zipper = Nothing
        assert(create(parameters, o))
        Return o
    End Function
End Module
